﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Kristall.Editor.Commands
{
    public abstract class MacroCommand : ICommand
    {
        public List<ICommand> Commands { get; set; }

        public MacroCommand()
        {
            Commands = new List<ICommand>();
        }

        public bool Execute()
        {
            return Commands.All(x => x.Execute());
        }

        public bool Undo()
        {
            List<ICommand> reverseOrdered = new List<ICommand>(Commands);
            reverseOrdered.Reverse();
            return reverseOrdered.All(x => x.Undo());
        }

        public string Name
        {
            get { return "Macro"; }
        }
    }
}
